//
//  LGChartDetailAlertCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/6.
//

#import "LGChartDetailAlertCell.h"

@interface LGChartDetailAlertCell()

/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *scoreLabel;
/**   */
@property (nonatomic , strong)UIImageView *tipView;

@end

@implementation LGChartDetailAlertCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.scoreLabel];
        [self.contentView addSubview:self.tipView];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(viewPix(17));
            make.centerY.equalTo(self.contentView);
        }];
        [self.scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(viewPix(80));
            make.centerY.equalTo(self.titleLabel);
        }];
        [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.scoreLabel.mas_right).offset(2);
            make.centerY.equalTo(self.scoreLabel);
            make.width.equalTo(@(viewPix(16)));
            make.height.equalTo(@(viewPix(18)));
        }];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.titleLabel.text = dataDic[@"title"];
    self.scoreLabel.text = dataDic[@"score"];
    if([dataDic[@"status"] isEqualToString:@"high"]){
        self.tipView.hidden = NO;
        self.tipView.image = [UIImage imageNamed:@"监测分数-偏高"];
        self.scoreLabel.textColor = [UIColor colorWithString:@"#D04442"];
        
    }else if ([dataDic[@"status"] isEqualToString:@"low"]){
        self.tipView.hidden = NO;
        self.tipView.image = [UIImage imageNamed:@"监测分数-偏低"];
        self.scoreLabel.textColor = [UIColor colorWithString:@"#E8B164"];
        
    }else{
        self.tipView.hidden = YES;
        self.scoreLabel.textColor = [UIColor colorWithString:@"#FFFFFF"];
    }
    CGFloat left = (self.titleLabel.text.length>0)?viewPix(80):viewPix(17);
    [self.scoreLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(left);
    }];
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#FFFFFF" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UILabel *)scoreLabel{
    if(!_scoreLabel){
        _scoreLabel = [UILabel lableWithText:@"" colorString:@"#FFFFFF" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _scoreLabel;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];
    }
    return _tipView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
